#include <stdio.h>

int count_chars(const char *filename)
{
    FILE *file = fopen(filename, "r");
    if (file == NULL)
    {
        printf("Error: File '%s' does not exist or cannot be opened\n", filename);
        return -1;
    }
    int count = 0;
    int c;
    while ((c = fgetc(file)) != EOF)
        count++;
    fclose(file);
    return count;
}

int main(int argc, char *argv[])
{
    if (argc != 3)
    {
        printf("Usage: wc.exe -c [filename]\n");
        return 1;
    }

    char *option = argv[1];
    char *filename = argv[2];

    if (strcmp(option, "-c") == 0)
    {
        int chars = count_chars(filename);
        if (chars != -1)
            printf("Characters: %d\n", chars);
    }
    else
    {
        printf("Error: Unknown option '%s'\n", option);
        return 1;
    }

    return 0;
}